package com.yuchao.springboot;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.List;

/**
 * https://www.jianshu.com/p/d5ffdccc4f5d
 * Spring 的类扫描器分析 - ClassPathBeanDefinitionScanner
 */
@SpringBootApplication
public class SpringbootClasspathBeanDefinitionScannerApplication implements BeanFactoryAware {

	private BeanFactory beanFactory;

	@Override
	public void setBeanFactory(final BeanFactory beanFactory) throws BeansException {
		this.beanFactory = beanFactory;

		//测试: springboot最顶级扫描包的路径，SpringbootClasspathBeanDefinitionScannerApplication的上一级目录
		List<String> pkgs = AutoConfigurationPackages.get(this.beanFactory);
	}



	public static void main(String[] args) {


		SpringApplication.run(SpringbootClasspathBeanDefinitionScannerApplication.class, args);
	}

}
